package chenji.dailykit;

import java.io.File;
import java.util.logging.Logger;
import org.bukkit.plugin.java.JavaPlugin;

import chenji.dailykit.ItemEditor.ItemEditorListener;
import chenji.dailykit.ItemEditor.ItemEditorManager;
import chenji.dailykit.ItemEditor.operationnode.OperationNodeItemLibrary;
import chenji.dailykit.commandlisteners.CommandDKAdmin;
import chenji.dailykit.commandlisteners.CommandItemEditor;
import chenji.dailykit.configuration.ConfigException;
import chenji.dailykit.kit.KitCenter;

/**
 * @author ChenJi Copyright (c) 2016 ChenJi. All rights reserved.
 */
public final class Main extends JavaPlugin {
	private static Logger logger;
	private static File DataFolder;
	private static KitCenter k;
	private static OperationNodeItemLibrary ONIL;
	private static ItemEditorManager m;

	public final void onEnable() {
		getLogger().info("-----------DailyKit----------");
		Main.logger = getLogger();
		getLogger().info("插件正在启动中，版本v1.1.0,作者：沉寂");
		Main.DataFolder = getDataFolder();
		ONIL = new OperationNodeItemLibrary();
		try {
			k = new KitCenter();
		} catch (ConfigException e) {
			e.printStackTrace();
		}
		m = new ItemEditorManager();
		getServer().getPluginCommand("DKAdmin").setExecutor(new CommandDKAdmin());
		getServer().getPluginCommand("ItemEditor").setExecutor(new CommandItemEditor());
		this.getServer().getPluginManager().registerEvents(new ItemEditorListener(), this);
		;

	}

	public final void onDisable() {
		getLogger().info("-----------DailyKit----------");
		getLogger().info("插件正在卸载。");
	}

	public static ItemEditorManager getItemEditorManager() {
		return m;
	}

	public static Logger getLog() {
		return Main.logger;
	}

	public static File getKDataFolder() {
		return Main.DataFolder;
	}

	public static KitCenter getKitCenter() {
		return k;
	}

	public static OperationNodeItemLibrary getOperationNodeItemLibrary() {
		return Main.ONIL;
	}
}